<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	    		xmlns:ui="http://java.sun.com/jsf/facelets"
	  			xmlns:h="http://java.sun.com/jsf/html"
	  			xmlns:f="http://java.sun.com/jsf/core"
	  			xmlns:p="http://primefaces.org/ui"
				template="/WEB-INF/layouts/standard.xhtml">
<ui:define name="notes">
	<p>
		This page uses the PrimeFaces data table backed by a lazily loaded DataModel (see <strong>HotelLazyDataModel.java</strong>).
		Page navigation is Ajax-based and uses JSF 2 partial rendering.
		The name and city columns support forward and reverse sorting. 
	</p>
	<p>
		The DataModel is created and stored in view scope when the view is first entered (see <strong>main-flow.xml</strong>). 
		When the user makes a selection, the selection is stored in a flow-scoped "hotel" variable before transitioning to the detail page. 
	</p>
</ui:define>
<ui:define name="content">
<h:form>
	<p:dataTable id="hotels" var="h" value="#{hotels}" paginator="true" dynamic="true"
			rows="#{hotels.pageSize}" page="#{hotels.currentPage}" lazy="true">
        <f:facet name="header">
        	Hotel Search Results<br/>
        	<p:commandLink value="Modify or start search again" action="changeSearch" styleClass="alt" />
        </f:facet>
		<p:column sortBy="#{h.name}">
			<f:facet name="header">Name</f:facet>
			#{h.name}
		</p:column>
		<p:column>
			<f:facet name="header">Address</f:facet>
			#{h.address}
		</p:column>
		<p:column sortBy="#{h.city}">
			<f:facet name="header">City, State</f:facet>
			#{h.city}, #{h.state}, #{h.country}
		</p:column> 
		<p:column>
			<f:facet name="header">Zip</f:facet>
			#{h.zip}
		</p:column>
		<p:column>
			<f:facet name="header">Action</f:facet>
			<p:commandButton id="viewHotelLink" value="View" action="select" icon="ui-icon-search">
				<f:setPropertyActionListener value="#{h}" target="#{hotels.selected}" />
			</p:commandButton>
		</p:column>
	</p:dataTable>
	<div><input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/></div>
</h:form>
</ui:define>
</ui:composition>